inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

173만명의 커뮤니티!! 함께 토론해봐요.

if 절 작성 시, input tool 완성시켜야 하나요?

미해결

if절 작성 시, Scanner 이런 툴을 작성하고 if 절 적어도 상관없나요? 아니면 문제 바이 문제 인가요? import java.util.*; psvm Scanner input = new Scanner(System.in); , , , if . . .. .

  • if
  • input
  • scanner
유학생 댓글 1 좋아요 0 조회수 182

Scanner, FileReader, BufferedReader 등 각각의 차이점 및 섹션 14. 퀴즈 #13의 호출 순서와 관련된 질문입니다...ㅎ

해결됨

나도코딩의 자바 기본편 - 풀코스 (20시간)

안녕하세요, 나도코딩 선생님...ㅎ 동영상 강의들 중 섹션 14. 입출력과 파일을 보다가 궁금증이 생겨서 질문을 하게 되었습니다...ㅎ (1) 섹션 14. 입출력과 파일을 공부하면서, 파일을 읽는 여러 가지 방법들을 접하고 있습니다. 공부하면서 BufferedReader, FileReader, Scanner등 여러 가지 방법들이 있는데, 이들은 어느 때 쓰이는 것이 가장 좋은가요? 예를 들면, BufferedReader는 큰 용량의 파일을 읽는데 적합하다 던가, 아니면 Scanner는 키보드 입력을 받는 것 외에도 파일을 읽고자 할 때, FileReader와 같은 역할을 한다 이런거요! 만약 어느 한 텍스트 파일을 읽고자 할 때, Scanner를 예로 들면, 이렇게 코드를 적어볼 수 있을까요? 모든 건 이미 import가 있다고 가정하고 작성해봤습니다...ㅎ: ... // 이전 코드 생략 try { File file = new File("testing.txt"); Scanner scanner = new Scanner(file); while(scanner.hasNext()) { System.out.println(scanner.next()); // 여기서 만약에 여러 줄들로 이루어진 텍스트에서 한 글자씩 따오려면, // 이전에 문자열 관련 질문 처럼 scanner.next().charAt을 쓰나요? } scanner.close(); } catch (FileNotFoundException e1) { e1.printStackTrace(); // 예외 처리 1 } catch (IOException e2) { e2.printStackTrace(); // 예외 처리 2 } (2) 섹션 14에 있는 퀴즈 #13과 관련된 질문입니다! 제가 try문 안의 String input; scanner의 호출 스택(순서)을/를 제대로 이해했는지 알고 싶습니다...ㅎ ... // 이전 코드 생략 Scanner scanner = new Scanner(System.in); try (BufferedReader br = new BufferedReader(new FileReader("saying.txt"))) { ... // 퀴즈 시작 및 제목 출력 String quiz; String answer; String input; while (true) { quiz = br.readLine(); answer = br.readLine(); if (quiz == null || answer == null) { break; } System.out.println(" (문제) " + quiz); System.out.println(" (답 입력) "); input = scanner.next(); ... // input.equal(answer), if-else문 생략 } ... } catch (IOException e) { e.printStackTrace(); // 예외 처리 } 여기 이 코드에서, quiz랑 answer는 1줄 1줄 br.readLine();을 통해 단어 및 문장들을 인식하는 반면, 입력하는 답안의 경우에는 우선 try문 안에서 String input;을 선언하고, 대입 연산자 = 를 통해 .next();로 입력을 받은 다음, string으로 선언된 input을 .equal();로 입력받은 값과 정답을 비교하여 최종 결과를 출력하는 건가요? 프로그래밍 언어를 공부하다보니 여러 질문들과 궁금증이 많이 쌓이는데, (특히 최근에 들어선 더 많아졌네요...ㅎ) 그 때마다 제 궁금증을 답글을 통해 잘 해소줘서 진심으로 감사합니다..ㅎ :)

  • java
  • 객체지향
  • 파일
  • file
  • 입출력
  • input
  • output
댓글 1 좋아요 1 조회수 959

input 태그 / flex 정렬

해결됨

[코드캠프] 시작은 프리캠프

안녕하세요. 취업을 목표로 공부하고 있는 코린이 입니다. 섹션2 CSS 파트의 "회원가입" 화제 과제를 하는 중에, 며칠동안 코드를 계속 수정하고 고쳐도 (아직 제 실력으로는) 해결이 어려운 부분들이 있어 질문을 남기게 되었습니다. 저는 맥북을 사용하고, chrome으로 구현하고 있습니다. <input> 관련 input[type="radio"] { appearance: none; border-radius: 50%; width: 20px; height: 19.95px; background-color: #ebebeb; border: 1px solid #d2d2d2; } <input type="radio" ~> 위의 input 태그의 외형을 CSS로 변경할 때 (특히, 배경 색상) 코드가 반영이 안되는 부분이 있어 인터넷 검색을 하다보니, appearance: none; 을 지정해 줘야 한다는 것을 알게 되었습니다. 이 부분에서, 'input 태그에 class 또는 id를 적용시킬 때 항상 appearance를 적용해야 하는지' 궁금합니다. 나머지는 다했는데... / <div> 속 <input>의 flex 정렬 과제의 90%는 구현했습니다.. 그런데 부모박스를 <div>로 지정하고 자식 박스에 <input> 태그가 포함되었을 때, position: flex; justify-content: row/column; 와 같은 flex 정렬 코드가 반영이 되지 않고 있습니다. 최대한 자력으로 해결해보려고 노력하고 있지만, 아직 제 실력이 부족하여 며칠을 고민해도 쉽게 해결하지 못하고 있습니다... 선생님의 고견이 절실한 순간입니다. 완강하는 그날까지! html <!DOCTYPE html> <html lang="ko"> <head> <title>회원가입</title> <link href="./02-signup_실습.css" rel="stylesheet"> </head> <body> <!-- 회색 배경 --> <div class="Graybg"> <!-- 회원가입 배경 --> <div class="SignUpbg"> <!-- Group5 --> <div class="Group5"> <!-- 회원가입을 위해~ --> <div class="Title"> 회원가입을 위해<br> 정보를 입력해주세요 </div> <!-- Group1 --> <div class="Group1"> <div class="Textbox">* 이메일</div> <div class="vector1"></div> </div> <!-- Group2 --> <div class="Group1"> <div class="Textbox">* 이름</div> <div class="vector2"></div> </div> <!-- Group3 --> <div class="Group1"> <div class="Textbox">* 비밀번호</div> <div class="vector2"></div> </div> <!-- Group4 --> <div class="Group1"> <div class="Textbox">* 비밀번호 확인</div> <div class="vector2"></div> </div> <!-- 성별 --> <div class="gender"> <!-- 여성 --> <div class="genderBox"> <div><input type="radio"></div> <div>여성</div> </div> <!-- 남성 --> <div class="genderBox"> <div><input type="radio"></div> <div>남성</div> </div> </div> <!-- 체크박스 --> <div class="checkBox"> <input type="checkbox"> <div class="genderText"> 이용약관 개인정보 수집 및 이용, 마케팅 활용 선택에 모두 동의합니다. </div> </div> <!-- 선 --> <div class="line"></div> <!-- 가입 버튼 --> <button> <div class="signUpText">가입하기</div> </button> </div> </div> </div> </body> </html> CSS .Graybg { position: absolute; width: 1920px; height: 1080px; background-color: #FFFFFF; border: 1px dotted black; display: flex; justify-content: center; align-items: center; } .SignUpbg { width: 670px; height: 960px; background: #FFFFFF; border: 1px solid #AACDFF; box-shadow: 7px 7px 39px rgba(0, 104, 255, 0.25); border-radius: 20px; display: flex; justify-content: center; align-items: center; } .Group5 { width: 470px; height: 818px; display: flex; flex-direction: column; justify-content: space-between; align-items: center; } .Title { box-sizing: border-box; width: 466px; height: 94px; font-family: 'Noto Sans CJK KR'; font-style: normal; font-weight: 700; font-size: 32px; line-height: 47px; color: #0068FF; } .Group1 { width: 466px; height: 80px; display: flex; flex-direction: column; justify-content: space-between; } /* 성별 */ .gender { width: 140px; height: 23.94px; position: flex; flex-direction: row; flex-wrap: nowrap; border: 1px dotted black; } .genderBox { width: 60px; height: 23.94px; display:flex; flex-direction: row; justify-content: space-between; align-items: center; border: 1px dotted black; } input[type="radio"] { appearance: none; border-radius: 50%; width: 20px; height: 19.95px; background-color: #ebebeb; border: 1px solid #d2d2d2; } .genderText { font-family: 'Noto Sans CJK KR'; font-style: normal; font-weight: 400; font-size: 16px; line-height: 24px; color: #000000; } /* 성별 */ /* 체크박스 */ .checkBox { position: flex; flex-direction: row; align-items: center; width: 454px; height: 21.06px; font-family: 'Noto Sans CJK KR'; font-style: normal; font-weight: 400; font-size: 14px; line-height: 21px; border: 1px dotted black; } input[type="checkbox"] { width: 20px; height: 20px; } .checkBoxText { width: 419px; height: 21px; font-family: 'Noto Sans CJK KR'; font-style: normal; font-weight: 400; font-size: 14px; line-height: 21px; color: #000000; } /* 체크박스 */ .vector1 { width: 466px; height: 0px; border: 1px solid #0068FF; } .vector2 { width: 466px; height: 0px; border: 1px solid #CFCFCF; } /* 선 */ .line { width: 470px; height: 1px; background: #E6E6E6; } /* 가입 버튼 */ button { box-sizing: border-box; display: flex; justify-content: center; align-items: center; width: 470px; height: 75px; background: #FFFFFF; border: 1px solid #0068FF; border-radius: 10px; } button:hover { background: yellowgreen; } .signUpText { width: 70px; height: 27px; font-family: 'Noto Sans CJK KR'; font-style: normal; font-weight: 400; font-size: 18px; line-height: 27px; text-align: center; color: #0068FF; }

  • html/css
  • javascript
  • input
  • flex
  • HTML/CSS
  • 정렬
강우주 댓글 1 좋아요 0 조회수 2270

input tag에 타임리프로 chekced를 넣는 방법

미해결

스프링 MVC 2편 - 백엔드 웹 개발 활용 기술

[질문 내용] 안녕하세요 강사님! 강의 잘 듣고 있습니다. 다름이 아니라 타임리프에서 chekced를 표기하는 방법을 알고 싶습니다! html 소스보기 사진 <div class="form-check form-check-inline"> <input type="radio" value="ETC" class="form-check-input" id="itemType3" name="itemType" /> <label for="itemType3" class="form-check-label" checked="checked" >기타</label> </div> 소스코드 <!-- radio button --> <div> <div>상품 종류</div> <div th:each="type : ${itemTypes}" class="form-check form-check-inline"> <input type="radio" th:field="*{itemType}" th:value="${type.name()}" class="form-check-input" th:checked="${(type.description == '기타')? 'true':'false'}" /> <label th:for="${#ids.prev('itemType')}" th:text="${type.description}" class="form-check-label" th:checked="${(type.description == '기타')? 'true':'false'}" > BOOK </label> </div> </div> 위처럼 표시했는데 label 태그에는 나오고 input태그에는 나오지가 않습니다 ㅠ 이유가 무엇일까요? 또 thymeleaf로 표기하려면 어떻게 해야할까요? 그리고 formController에서 초기값을 설정하는 방법은 직접 해봤습니다! 타임리프에서 조건을 줘서 checked를 주는 방식이 궁금합니다! 감사합니다 ㅎㅎ

  • tyhmeleaf
  • checcked
  • MVC
  • input
  • spring
  • html
yj Ryu 댓글 1 좋아요 0 조회수 2088

split 부분에서 input.find(delimiter)의 값에 대한 궁금증 입니다!

미해결

10주완성 C++ 코딩테스트 | 알고리즘 코딩테스트

큰돌님 안녕하세요! C++ 교안을 공부하다가 split 부분에서 궁금한 것이 생겨서 질문 드립니다! while((pos=input.find(delimiter)) != string::npos){ cout << input.find(delimiter) << "\n"; token = input.substr(0, pos); ret.push_back(token); input.erase(0, pos+delimiter.length()); } 이 함수에서 find 반환값이 궁금해 cout로 출력을 시켜봤습니다. 예상대로는 "안녕하세요 큰돌이는 바보에요 정말이에요!" 문자열의 스페이스 index인 5, 4, 4가 나와야할 것 같았는데 두배인 10, 8, 8이 출력이 되었고 다른 컴파일러를 사용했을 때는 세배인 15, 12, 12 출력 되었습니다. 혹시 이렇게 배수로 출력되는 이유가 따로 있는지 궁금합니다!

  • split
  • value
  • C++
  • find
  • 코테 준비 같이 해요!
  • input
박근철 댓글 1 좋아요 0 조회수 382

새로고침시 값 유지

미해결

[리뉴얼] React로 NodeBird SNS 만들기

제로초님! 로그인시 작성했던 input안에 내용이 로그아웃했는데도 그대로 남아있는 건 어떻게 하신건지 궁금합니다!

  • input
  • react
  • express
  • nodejs
  • redux
  • Next.js
제이제이 댓글 3 좋아요 0 조회수 717

인기 태그

인프런 TOP Writers

주간 인기글